
#include "NodeAction.h"
#include <utility>
#include <iostream>

using namespace npInterpreter;
using namespace std;


NodeAction::NodeAction() : Node() // class inheritance
{
    //To initialize data member;
    this->action = "";
}

NodeAction::~NodeAction()
{
    //To delete dynamic data member
}

NodeAction::NodeAction(const NodeAction& cpy) : Node(cpy) // class inheritance
{
    //To copy data member
    this->action = cpy.action;
}

NodeAction& NodeAction::operator=(const NodeAction& asn)
{
    if (this == &asn)
    {
        return *this;
    }
    else
    {
        //To invoke base class operator=
        Node::operator=(asn);
        //To assign data member, note to delete dynamic member if exists.
        this->action = asn.action;

        return *this;
    }
}

NodeAction::NodeAction(NodeAction&& mov) noexcept : Node(move(mov)) // class inheritance
{
    //to move data
    this->action = move(mov.action);
}

NodeAction& NodeAction::operator=(NodeAction&& mva) noexcept
{
    if (this == &mva)
    {
        return *this;
    }
    else
    {
        //to inform base class to move data
        Node::operator=(move(mva));
        // to move data
        this->action = move(mva.action);
        return *this;
    }
}

NodeAction* NodeAction::clone() const
{
    //return new
    return new NodeAction(*this);
}

//other constructors
NodeAction::NodeAction(const string& action) : Node()
{
    this->action = action;
}

//public methods
string NodeAction::interpret() throw()
{
    if (this->action == "move")
    {
        return "移动";
    }
    else if (this->action == "run")
    {
        return "快速移动";
    }
    else
    {
        return "无效指令";
    }
}

//protected methods

//private methods

//others
